home *** CD-ROM | disk | FTP | other *** search
- package netscape.applet;
-
- class IntTable {
- int count = 0;
- int[] keys = new int[8];
- Object[] values = new Object[8];
-
- public IntTable() {
- }
-
- public int count() {
- return this.count;
- }
-
- public int keyAt(int var1) {
- if (var1 >= this.count) {
- throw new ArrayIndexOutOfBoundsException(var1 + " >= " + this.count);
- } else {
- return this.keys[var1];
- }
- }
-
- public Object elementAt(int var1) {
- if (var1 >= this.count) {
- throw new ArrayIndexOutOfBoundsException(var1 + " >= " + this.count);
- } else {
- return this.values[var1];
- }
- }
-
- public int indexOfKey(int var1) {
- int var3 = this.count;
-
- for(int var2 = 0; var2 < var3; ++var2) {
- if (this.keys[var2] == var1) {
- return var2;
- }
- }
-
- return -1;
- }
-
- public int indexOfValue(Object var1) {
- int var3 = this.count;
-
- for(int var2 = 0; var2 < var3; ++var2) {
- if (this.values[var2].equals(var1)) {
- return var2;
- }
- }
-
- return -1;
- }
-
- public Object get(int var1) {
- int var2 = this.indexOfKey(var1);
- return var2 < 0 ? null : this.elementAt(var2);
- }
-
- public Object put(int var1, Object var2) {
- Object var3 = this.remove(var1);
- this.ensureCapacity(this.count + 1);
- this.keys[this.count] = var1;
- this.values[this.count] = var2;
- ++this.count;
- return var3;
- }
-
- public Object remove(int var1) {
- int var2 = this.indexOfKey(var1);
- if (var2 < 0) {
- return null;
- } else {
- Object var4 = this.values[var2];
- int var3 = this.count - var2 - 1;
- if (var3 > 0) {
- System.arraycopy(this.keys, var2 + 1, this.keys, var2, var3);
- System.arraycopy(this.values, var2 + 1, this.values, var2, var3);
- }
-
- --this.count;
- this.keys[var2] = 0;
- this.values[var2] = null;
- return var4;
- }
- }
-
- public void ensureCapacity(int var1) {
- if (this.keys.length < var1) {
- int var2 = this.keys.length * 2;
- if (var2 < var1) {
- var2 = var1;
- }
-
- int[] var3 = new int[var2];
- Object[] var4 = new Object[var2];
- System.arraycopy(this.keys, 0, var3, 0, this.count);
- System.arraycopy(this.values, 0, var4, 0, this.count);
- this.keys = var3;
- this.values = var4;
- }
-
- }
- }
-